const TOKEN = '__token__'

export function getToken () {
  return localStorage.getItem(TOKEN)
}
export function setToken (token) {
  localStorage.setItem(TOKEN, token)
}
export function removeToken () {
  localStorage.removeItem(TOKEN)
}
export function generateUrl (url, data) {
  let paramString = ''
  for (var k in data) {
    let value = data[k] ? data[k] : ''
    paramString += '&' + k + '=' + encodeURIComponent(value)
  }
  paramString = paramString ? paramString.substring(1) : ''
  url += (url.indexOf('?') < 0 ? '?' : '&') + paramString
  return url
}
export function isWechatBroswer () {
  var ua = window.navigator.userAgent.toLowerCase()
  if (ua.indexOf('micromessenger') !== -1) {
    return true
  } else {
    return false
  }
}
